<!--
 * @Version: 1.0
 * @Date: 2021-04-10 16:18:26
 * @LastEditTime: 2021-04-19 10:04:47
 * @Description:
-->
<template>
  <el-card class="app-container">
    <div>
      <el-form :model="dataForm">
        <el-form-item label="自动发货开关设置">
          <el-switch
            v-model="dataForm.value"
            active-color="#13ce66"
            inactive-color="#ff4949"
            active-value="1"
            inactive-value="2"
            @change="change"
          />
        </el-form-item>
      </el-form>
    </div>
  </el-card>

</template>

<script>
export default {
  name: 'DeliveryOrderSetting',
  data() {
    return {
      componentName: 'DeliveryOrderSetting',
      dataForm: {
        value: ''
      }
    }
  },
  created() {
    this.obtainInfo()
  },
  methods: {
    // 订单配置详情
    obtainInfo() {
      this.$http.get(`/config/info/23`).then((res) => {
        if (res.code === 10000) {
          this.dataForm.value = res.data.value
        }
      })
    },
    change(val) {
      this.$http.put(`/config/23`, { value: val }).then((res) => {
        if (res.code === 10000) {
          this.$message.success('设置成功')
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
